﻿namespace Shanda.DevFx.Security.Web.Pages
{
    using Shanda.DevFx.Security;
    using Shanda.DevFx.Utils;
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class LogoutPage : Page
    {
        protected Label lblMessage;

        protected virtual void InitData()
        {
            if (base.get_User().get_Identity().get_IsAuthenticated())
            {
                Authentication authentication = base.get_User() as Authentication;
                if (authentication != null)
                {
                    HttpCookie emptyAuthCookie = authentication.GetEmptyAuthCookie();
                    base.get_Response().AppendCookie(emptyAuthCookie);
                    WebHelper.ShowMessage(string.Empty, "window.top.location.href='login.aspx'", true, false);
                }
                else
                {
                    this.lblMessage.set_Text("配置错误");
                }
            }
            else
            {
                this.lblMessage.set_Text("尚未认证");
            }
        }

        private void InitializeComponent()
        {
        }

        protected override void OnInit(EventArgs e)
        {
            this.InitializeComponent();
            base.OnInit(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.InitData();
        }
    }
}

